#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x7f7f7f7f
const int N = 1e5 + 10;
int T,n,m,L,V;
int d[N],v[N],a[N],p[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--){
        cin >> n >> m >> L >> V;
        int flaga = 1,flagb = 1;
        for(int i = 1;i <= n;i++){
            d[i] = 0,v[i] = 0,a[i] = 0;
        }
        for(int i = 1;i <= n;i++){
            cin >> d[i] >> v[i] >> a[i];
            if(a[i] != 0) flaga = 0;
            if(a[i] <= 0) flagb = 0;
        }
        int mxp = -1;
        for(int i = 1;i <= m;i++){
            p[i] = 0;
        }
        for(int i = 1;i <= m;i++){
            cin >> p[i];
            mxp = max(mxp,p[i]);
        }
        if(flaga){
            int ans = 0;
            int x = 1;
            for(int i = 1;i <= n;i++){
                if(d[i] > mxp){
                    continue;
                }
                if(v[i] > V) ans++;
            }
            if(ans == 0) x = 0;
            cout << ans << " " << m - x << "\n";
        }
        if(flagb){
            int ans = 0;
            int x = 1;
            for(int i = 1;i <= n;i++){
                if(d[i] > mxp){
                    continue;
                }
                double sq = 1.0 * v[i] * v[i] + 2.0 * a[i] * (mxp - d[i]);
                double vv = sqrt(sq);
                if(vv > (double)(V + 0.0001)) ans++;
            }
            if(ans == 0) x = 0;
            cout << ans << " " << m - x << "\n";
        }
    }
    return 0;
}
